package com.hq.ims.data.vo;

import com.hq.authority.utils.AppUtils;
import com.hq.ims.data.config.verification.VdAdd;
import com.hq.ims.data.config.verification.VdEdit;
import com.hq.ims.data.entity.UserTodoStatistics;
import com.hq.ims.data.entityenum.EnumUserTodoType;
import com.hq.ims.data.vo.auth.BaseRowAuthVo;
import com.hq.utils.util.ListUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.stream.Collectors;


/**
 * @author 蒋柏平
 * @since 20241108
 */
@Mapper
public interface UserTodoStatisticsMapstruct {

    UserTodoStatisticsMapstruct INSTANCE = Mappers.getMapper(UserTodoStatisticsMapstruct.class);

    //-------------------------------- 转换VO类 --------------------------------

    @Mappings({
    })
    UserTodoStatisticsVo toUserTodoStatisticsVo(UserTodoStatistics source);

    default List<UserTodoStatisticsVo> toUserTodoStatisticsVoList(List<UserTodoStatistics> source) {
        if (source == null) {
            return ListUtils.newEmptyList();
        }
        return source.stream().map(this::toUserTodoStatisticsVo).collect(Collectors.toList());
    }

    //-------------------------------- 以下为自定义类[输出对象] --------------------------------

    @ApiModel(value = "原始对象的扩展类")
    @Data
    class UserTodoStatisticsVo extends UserTodoStatistics {

    }

    @ApiModel(value = "行级权限对象")
    @Data
    class UserTodoStatisticsRowAuthVo extends BaseRowAuthVo {

        //自定义其它行级权限

        //构造函数
        public UserTodoStatisticsRowAuthVo(UserTodoStatistics entity) {
            //当前操作用户ID
            String userId = AppUtils.getUserId();
        }

    }


    //-------------------------------- 以下为自定义类[输入对象] --------------------------------

    @ApiModel(value = "搜索VO")
    @Data
    class PageSearchVo {

    }

    @ApiModel(value = "添加和修改对象")
    @Data
    class SaveVo {

        @NotNull(message = "用户待办类型不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "用户待办类型")
        private EnumUserTodoType userTodoType;

        @NotNull(message = "待办类型数量不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "待办类型数量")
        private Integer userTodoTypeCount;

        private String companyId;

        private String userId;

        private String tableId;

    }

    @Data
    class ClearTodo {

        @NotNull(message = "待办类型不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "待办类型ID")
        private EnumUserTodoType userTodoType;

        @NotNull(message = "清除数量不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "清除数量")
        private Integer clearCount;

        @ApiModelProperty(value = "公司Id")
        private String companyId;

        @ApiModelProperty(value = "公司Id")
        private String userId;

    }

    //-------------------------------- springboot验证标识 --------------------------------

}
